package com.xjl.shujujiegou;

import com.xjl.utils.SortUtil;

/**
 * @描述:
 * @作者: XUJIANLIN
 */
public class TwoArray {

    public static void printTwoArray_2(int[][] twoarr){

    }


    /**
     * 将二维数组顺时针输出
     * @param twoarr
     */
    public static void printTwoArray_1(int[][] twoarr){
        //左上角 (0,0)
        //右下角 ()

        int leftX = 0;
        int leftY = 0;

        int rightX = twoarr[0].length -1;
        int rightY = twoarr.length -1;


        while(leftX <= rightX) {
            for ( int i = leftX; i < rightX ; i++) {
                System.out.print ( twoarr[leftY][i] + " ");
            }

            for ( int i = leftY; i < rightY ; i++) {
                System.out.print ( twoarr[i][rightX] + " ");
            }

            for ( int i = rightX; i > leftX ; i--) {
                System.out.print ( twoarr[rightY][i] + " ");
            }
            for ( int i = rightY; i > leftY ; i--) {
                System.out.print ( twoarr[i][leftX] + " ");
            }
            System.out.println("");
            leftX++;
            leftY++;
            rightX--;
            rightY--;
        }







    }



    public static void main(String[] args) {
        //测试二维数组能否顺时针输出
        int[][] twoArry = SortUtil.getTwoArry();
        printTwoArray_1(twoArry);
        /**********/




    }
}
